const mutations = {
  addlist(state, payload) {//同一个商品数量增加
    payload.count++;
    console.log(payload.count)

  },
  pushlist(state, payload) {
    //没有的商品增加到购物车中
    payload.count = 1
    payload.ckecked = true;   //注意选中不选中要在模型里面加上这个，要记录在对象里面
    state.cartList.push(payload);
  }, buttonup(state, payload) {

    payload.count += 1

  },
  buttondown(state, payload) {
    payload.count -= 1
    if (payload.count < 1) {
      console.log("我能进来第一层")
      // console.log(state.cartList[1].iid+222222222222)
      
      for (let i = 0; i < state.cartList.length; i++) {
        if (state.cartList[i].iid == payload.iid) {
          console.log(state.cartList[i].iid)
          console.log(payload.iid)
          state.cartList.splice(i,1);
        }
      }

    }
  },alltrue(state){//判断全选为false
    state.cartList.forEach(element => {
      element.ckecked=false
  });

  },allfalse(state){//判断全选为true
    state.cartList.forEach(element => {
      element.ckecked=true
  });
   } 
  
}

export default mutations